home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 2.iso / dist / fw_libxml.idb / usr / freeware / include / gnome-xml / encoding.h.z / encoding.h
C/C++ Source or Header  |  2001-04-12  |  4KB  |  115 lines

  1. /*
  2.  * encoding.h : interface for the encoding conversion functions needed for
  3.  *              XML
  4.  *
  5.  * Related specs: 
  6.  * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies
  7.  * [ISO-10646]    UTF-8 and UTF-16 in Annexes
  8.  * [ISO-8859-1]   ISO Latin-1 characters codes.
  9.  * [UNICODE]      The Unicode Consortium, "The Unicode Standard --
  10.  *                Worldwide Character Encoding -- Version 1.0", Addison-
  11.  *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is
  12.  *                described in Unicode Technical Report #4.
  13.  * [US-ASCII]     Coded Character Set--7-bit American Standard Code for
  14.  *                Information Interchange, ANSI X3.4-1986.
  15.  *
  16.  * See Copyright for the status of this software.
  17.  *
  18.  * Daniel.Veillard@w3.org
  19.  */
  20.  
  21. #ifndef __XML_CHAR_ENCODING_H__
  22. #define __XML_CHAR_ENCODING_H__
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. /**
  29.  * Predefined values for some standard encodings
  30.  */
  31. typedef enum {
  32.     XML_CHAR_ENCODING_ERROR=   -1, /* No char encoding detected */
  33.     XML_CHAR_ENCODING_NONE=    0, /* No char encoding detected */
  34.     XML_CHAR_ENCODING_UTF8=    1, /* UTF-8 */
  35.     XML_CHAR_ENCODING_UTF16LE=    2, /* UTF-16 little endian */
  36.     XML_CHAR_ENCODING_UTF16BE=    3, /* UTF-16 big endian */
  37.     XML_CHAR_ENCODING_UCS4LE=    4, /* UCS-4 little endian */
  38.     XML_CHAR_ENCODING_UCS4BE=    5, /* UCS-4 big endian */
  39.     XML_CHAR_ENCODING_EBCDIC=    6, /* EBCDIC uh! */
  40.     XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
  41.     XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
  42.     XML_CHAR_ENCODING_UCS2=    9, /* UCS-2 */
  43.     XML_CHAR_ENCODING_8859_1=    10,/* ISO-8859-1 ISO Latin 1 */
  44.     XML_CHAR_ENCODING_8859_2=    11,/* ISO-8859-2 ISO Latin 2 */
  45.     XML_CHAR_ENCODING_8859_3=    12,/* ISO-8859-3 */
  46.     XML_CHAR_ENCODING_8859_4=    13,/* ISO-8859-4 */
  47.     XML_CHAR_ENCODING_8859_5=    14,/* ISO-8859-5 */
  48.     XML_CHAR_ENCODING_8859_6=    15,/* ISO-8859-6 */
  49.     XML_CHAR_ENCODING_8859_7=    16,/* ISO-8859-7 */
  50.     XML_CHAR_ENCODING_8859_8=    17,/* ISO-8859-8 */
  51.     XML_CHAR_ENCODING_8859_9=    18,/* ISO-8859-9 */
  52.     XML_CHAR_ENCODING_2022_JP=  19,/* ISO-2022-JP */
  53.     XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
  54.     XML_CHAR_ENCODING_EUC_JP=   21 /* EUC-JP */
  55. } xmlCharEncoding;
  56.  
  57. /**
  58.  * xmlCharEncodingInputFunc:
  59.  * @out:  a pointer ot an array of bytes to store the UTF-8 result
  60.  * @outlen:  the lenght of @out
  61.  * @in:  a pointer ot an array of chars in the original encoding
  62.  * @inlen:  the lenght of @in
  63.  *
  64.  * Take a block of chars in the original encoding and try to convert
  65.  * it to an UTF-8 block of chars out.
  66.  *
  67.  * Returns the number of byte written, or -1 by lack of space.
  68.  */
  69. typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int outlen,
  70.                                          unsigned char* in, int inlen);
  71.  
  72.  
  73. /**
  74.  * xmlCharEncodingInputFunc:
  75.  * @out:  a pointer ot an array of bytes to store the result
  76.  * @outlen:  the lenght of @out
  77.  * @in:  a pointer ot an array of UTF-8 chars
  78.  * @inlen:  the lenght of @in
  79.  *
  80.  * Take a block of UTF-8 chars in and try to convert it to an other
  81.  * encoding.
  82.  *
  83.  * Returns the number of byte written, or -1 by lack of space, or -2
  84.  *     if the transcoding failed.
  85.  */
  86. typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int outlen,
  87.                                           unsigned char* in, int inlen);
  88.  
  89. /*
  90.  * Block defining the handlers for non UTF-8 encodings.
  91.  */
  92.  
  93. typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
  94. typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
  95. struct _xmlCharEncodingHandler {
  96.     char                       *name;
  97.     xmlCharEncodingInputFunc   input;
  98.     xmlCharEncodingOutputFunc output;
  99. };
  100.  
  101. void    xmlInitCharEncodingHandlers    (void);
  102. void    xmlCleanupCharEncodingHandlers    (void);
  103. void    xmlRegisterCharEncodingHandler    (xmlCharEncodingHandlerPtr handler);
  104. xmlCharEncoding xmlDetectCharEncoding    (const unsigned char* in);
  105. xmlCharEncoding xmlParseCharEncoding    (const char* name);
  106. xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler(xmlCharEncoding enc);
  107. xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name);
  108.  
  109.  
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113.  
  114. #endif /* __XML_CHAR_ENCODING_H__ */
  115.